|
|
|
|
|
|
|
You can also use the INSERT INTO statement to append rows to tables in another database. You accomplish this by adding an IN clause to the first part of the statement. For example, you can add rows from the JobTitles table in SQLVB05.MDB to a similar table in another database called SQLVB05B.MDB. The syntax for the IN clause of an INSERT INTO_FROM statement is |
|
|
|
|
|
|
|
|
IN "DatabaseFileName" "DatabaseFormat" |
|
|
|
|
|
|
|
|
DatabaseFileName is the complete database filename including the drive identifier and the path name of the destination (or external) database. DatabaseFormat is the name of the database format of the destination database, such as FoxPro, dBASE, Paradox, and so on. For example, if you want to update TableOne in the external database called EXTERNAL.MDB on drive C in the directory called DB, you would use the following IN clause for the SELECT INTO statement: |
|
|
|
|
|
|
|
|
SELECT INTO TableOne IN "c:\db\external.mdb" "access" |
|
|
|
|
|
|
|
|
Listing 15.4 shows how this is done using a real set of database files. Use SQL-VB5 to load and edit SQLVB05.SQV to match the modifications outlined in Listing 15.4. Save the script and execute it. Your results should look similar to those in Figure 15.4. |
|
|
|
|
|
|
|
|
Listing 15.4. Adding the IN clause. |
|
|
|
|
|
|
|
|
//
// sqlvb05.sqv - Testing the INSERT INTO keyword
//
// create sqlvgb05b database
dbMake sqlvb05b.mdb;
// make a table
CREATE TABLE OtherTitles
(JobCounter COUNTER,
JobID TEXT(5) CONSTRAINT PKJobTitle PRIMARY KEY,
JobName TEXT(20),
JobPay CURRENCY,
JobDesc MEMO
);
// insert some rows
INSERT INTO OtherTitles (JobID, JobName, JobDesc, JobPay) VALUES
('J004',
'Line Foreman',
'Supervises production line',
'30000'
);
INSERT INTO OtherTitles (JobID, JobName, JobDesc, JobPay) VALUES
('J005',
'Line Worker',
'Does what the Line Foreman tells him to do',
'25000'
);
// show results |
|
|
|
|
|